/*
 * SplitPaneDelegate.h  0.4.0 / Dec 05, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef SPLITPANEDELEGATE_H
#define SPLITPANEDELEGATE_H

#include "Cute4jSwing.h"

#include "ComponentDelegate.h"
#include "QSplitterAdapter.h"

// SplitPaneDelegate Class. ----------------------------------------------------

/*!
 * \brief SplitPane Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT SplitPaneDelegate : public ComponentDelegate
{
  Q_OBJECT
protected:
  SplitPaneDelegate(JNIEnv *env, jobject obj);
public slots: // native calls
  void setLeftComponent(JNIEnv *env, jlong componentDelegate);
  void setRightComponent(JNIEnv *env, jlong componentDelegate);
  void setOrientation(JNIEnv *env, jint orientation);
  void setContinuousLayout(JNIEnv *env, jboolean continuousLayout);
  void setResizeWeight(JNIEnv *env, jdouble resizeWeight);
  jint getDividerSize(JNIEnv *env);
  void setDividerSize(JNIEnv *env, jint dividerSize);
  void setDividerLocation(JNIEnv *env, jint dividerLocation);
  void setOneTouchExpandable(JNIEnv *env, jboolean oneTouchExpandable);
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
  static jlong newInstance(JNIEnv *env, jobject obj);
public: // native callbacks
  void dividerLocationChanged(jint dividerLocation);
public:
  inline QSplitterAdapter *qSplitterAdapter() const;
protected slots:
  void splitterMovedSlot(int position, int index);
private:
  static jmethodID sm_dividerLocationChangedMID;
};

// SplitPaneDelegate :: Public Inline Member Function. -------------------------

/*!
 * \brief Returns QSplitterAdapter adaptee.
 *
 * \return QSplitterAdapter adaptee
 */
inline QSplitterAdapter *SplitPaneDelegate::qSplitterAdapter() const
{
  return static_cast<QSplitterAdapter *>(qObject());
}

// Macro Definition. -----------------------------------------------------------

#define SPLIT_PANE_DELEGATE (reinterpret_cast<SplitPaneDelegate *>(delegate))

#endif // SPLITPANEDELEGATE_H
